package com.geekca.d8.studentinfo;

import java.util.ArrayList;
import java.util.Scanner;

public class TestStudentInfoNameQuery {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();

        students.add(new Student("20180302", "叶孤城", 23, "护理一班"));
        students.add(new Student("20180303", "东方不败", 23, "推拿二班"));
        students.add(new Student("20180314", "西门吹雪", 26, "中药学四班"));
        students.add(new Student("20180315", "梅超风", 26, "神经科2班"));

        Scanner scanner = new Scanner(System.in);
        while (true) {
            Boolean flag = true;
            System.out.println("请输入姓名:");
            String studentName = scanner.next();
            for (int i = 0; i < students.size(); i++) {
//                if (studentNumber.equals(students.get(i).getStuNum())) {
                if (students.get(i).getStuName().contains(studentName)) {
                    System.out.println("查询到学生信息: ");
                    System.out.println(students.get(i));
                    System.out.println();
                    flag=false;
//                    break;
                }
            }
            if (flag){
                System.out.println("没有相关信息，请检查姓名重新查询。\n");
            }
        }
    }
}
